<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>URL资源管理</title>
	<!--[if IE]>
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<![endif]-->
	<!-- Main Stylesheet --> 
	<link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css" type="text/css" />
	<!-- Your Custom Stylesheet --> 
	<link rel="stylesheet" href="<%=request.getContextPath()%>/css/custom.css" type="text/css" />
	<link href="<%=request.getContextPath()%>/lib/thickbox/thickbox.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath()%>/lib/jquery/jquery.autocomplete.css" type="text/css" rel="stylesheet"/>
	<%@include file="/include/header.jsp" %>
	<style type="text/css">
		#show_area input[type="text"]{
			font-family:宋体;黑体;幼圆;楷体_GB2312;仿宋_GB2312;Arial,Helvetica,sans-serif;
			border:0px;width:100%;height:100;
		}
		.noborder {border:0px none; overflow:auto;}
	</style>
	<script src="<%=request.getContextPath()%>/lib/jquery/jquery-1.4.2.min.js"></script>
	<script src="<%=request.getContextPath()%>/js/administry.js"></script>
	<script src="<%=request.getContextPath()%>/lib/validator/formValidator_min.js"></script>
	<script src="<%=request.getContextPath()%>/lib/validator/formValidatorRegex.js"></script>
	<script src="<%=request.getContextPath()%>/lib/jquery/jquery.form.js"></script>
	<script src="<%=request.getContextPath()%>/lib/thickbox/thickbox.js"></script>
	<script src="<%=request.getContextPath()%>/lib/jquery/jquery.autocomplete.pack.js"></script>
	<script src="<%=request.getContextPath()%>/js/function.js"></script>
	<script src="<%=request.getContextPath()%>/js/page/pageRender.js"></script>
	<script type="text/javascript">
	<sec:authorize ifAnyGranted="ADMIN,URL_ADD">
	$(document).ready(function(){
		$.formValidator.initConfig({
			formID:"addUrl",
			onError:function(msg){
				Alert(msg)
			},
			onSuccess:function(){
				if( confirm("准备提交数据，是否继续？") ){
					Mask.show();
					$('#addUrl').ajaxSubmit(Ajax.callback);
				}
				return false;
			}
		});
		$("#name").formValidator({
			onShow:"请输入URL资源名",
			onFocus:"2-50个字符"
		}).inputValidator({min:2,max:50});
		$("#url").formValidator({
			onShow:"请输入URL",
			onFocus:"最多255个字符"
		}).inputValidator({min:2,max:255});
	});
	function showAddUrlForm(){
		getById("addUrl").reset();
		showBox("#TB_inline?height=120&width=500&inlineId=edit_container", "增加URL资源");
	}
	</sec:authorize>
	window.onload = init;
	function init(){
		
		window["pr"] = new PageRender({
			id: 'pr',
			method: 'POST',
			url:'<%=request.getContextPath()%>/protected/system/listUrl.action',
			start: <s:property value="start"/>,
			limit: <s:property value="limit"/>,
			total: <s:property value="total"/>,
			data: {
				"urlName" : "#s_urlName"
			}
		});
		window["pr"].render(getById("page_bar"));
	}
	function doSearch(){
		Mask.show();
		window["pr"].position(1);
	}
	
	$(document).ready(function(){
		Administry.contextBoxInit();
	});
	</script>
</head>
<body>
	<%@include file="/include/body.jsp" %>
	
<s:if test="flag">
	<!-- 显示操作成功 -->
	<script type="text/javascript">
		showTip("操作成功");
	</script>
</s:if>

<!-- Wrapper -->
<div class="wrapper">
	
    <div class="content-box resizable" id="query_area">
    	<header>
			<h3>搜索</h3>
		</header>
		<section>
		<table class="no-style">
			<tbody>
			<tr>
				<td>
		        	<span>URL资源名关键字:
		        		<input id="s_urlName" type="text" name="s_urlName" value="<s:property value="urlName"/>" class="input input_wa" />
		        	</span>
		            <span>
						<button class="btn" type="submit" onclick="doSearch();"><span class="icon icon-search"></span>搜 索</button>
					</span>
				</td>
			</tr>
			</tbody>
		</table>
		</section>
	</div>
    <div class="content-box" id="show_area">
	<header>
		<h3>
    		<span>URL资源列表</span>
    	</h3>
    	<div>
			 <span>
	    		<span>
	    			<a class="btn btn-gray" href="javascript:void(0)" onclick="doSearch();"><span class="icon icon-refresh"></span>刷新</a>
	    		</span>
				 <sec:authorize ifAnyGranted="ADMIN,URL_ADD">
	    		<span>
	    			<a class="btn" href="javascript:void(0)" onclick="showAddUrlForm();"><span class="icon icon-add"></span>增加URL资源..</a>
		    	</span>
			    </sec:authorize>
	    	</span>
	    </div>
    </header>
    <section>
     <table class="display stylized" id="data_table">
     	<thead>
		<tr>
			<th>序号</th><th>URL资源名</th>
			<th>URL</th><th>操作</th>
		</tr>
		</thead>
		<tbody>
		<s:if test="urls != null">
			<s:iterator value="urls" status="urlstatus">
			<form id="form_<s:property value="code"/>" action="<s:url value='editUrl.action'></s:url>" method="post">
				<input type="hidden" name="url.code" value="<s:property value="code"/>"/>
				<tr>
					<td><s:property value="#urlstatus.index + 1 + start"/></td>
			 		<td><input type="text" name="url.name" value="<s:property value="name"/>"/></td>
			 		<td><input type="text" name="url.url" value="<s:property value="url"/>"/></td>
			 		<td style="white-space:nowrap">
			 		<sec:authorize ifAnyGranted="ADMIN,URL_EDIT">
			 			<a href="javascript:void(0);" onclick="if(confirm('请确认')){Mask.show();$('#form_<s:property value="code"/>').ajaxSubmit(Ajax.callback);}">［更新］</a>
			 		</sec:authorize>
			 		<sec:authorize ifAnyGranted="ADMIN,URL_DELETE">
			 			<a href="javascript:void(0);" onclick="if(confirm('是否删除URL?')){document.location.href='<s:url value='delUrl.action?id=%{code}'></s:url>';}">［删除］</a>
			 		</sec:authorize>
				 	</td>
			 	</tr>
			 	</form>
			</s:iterator>
		 </s:if>
		 </tbody>
	</table>
	<div id="page_bar"></div>
	</section>
	</div>
</div>

<div id="edit_container" style="display:none;">
 <div id="edit_area">
 <sec:authorize ifAnyGranted="ADMIN,URL_ADD">
	<s:form id="addUrl" action="addUrl.action" method="post" theme="simple">
	<table class="no-style">
		<tr>
			<td><label class="required">URL资源名</label></td>
			<td><input id="name" type="text" name="url.name" value=""/></td>
			<td><div id="nameTip"></div></td>
		</tr>
		<tr>
			<td><label class="required">URL</label></td>
			<td><input id="url" type="text" name="url.url" value=""/></td>
			<td><div id="urlTip"></div></td>
		</tr>
	</table>
	<div class="form-btn">
		<button class="btn btn-green" type="submit"><span class="icon icon-ok"></span>提 交</button>
		<button class="btn" type="reset" onclick="javascript:tb_remove();"><span class="icon icon-close"></span>取消</button>
	</div>
	</s:form>
</sec:authorize>
</div>
</div>
</body>
</html>